<?php
/**
 * The template for displaying content in the single.php template
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */
?>
<!-- Libs CSS -->
		<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/css/bootstrap.css">
		<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/css/fonts/font-awesome/css/font-awesome.css">
		<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/vendor/flexslider/flexslider.css" media="screen" />
		<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/vendor/fancybox/jquery.fancybox.css" media="screen" />
                <!-- Head Libs -->
		<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/modernizr.js"></script>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
	<header class="entry-header">
		<h1 class="entry-title"><?php the_title(); ?></h1>		
	</header><!-- .entry-header -->
        
        <?php if( kd_mfi_get_featured_image_id('featured-image-2', 'post' ) != NULL ) 
                $have_feature2 = true; else $have_feature2 = false; ?>
        <?php if( kd_mfi_get_featured_image_id('featured-image-3', 'post' ) != NULL ) 
                $have_feature3 = true; else $have_feature3 = false; ?>
        
	<div class="row">
            <div class="span6">
                <div data-plugin-options="{&quot;animation&quot;:&quot;slide&quot;, &quot;animationLoop&quot;: true, &quot;maxVisibleItems&quot;: 1}" class="flexslider flexslider-center-mobile flexslider-simple normal-device flexslider-init flexslider-control-nav flexslider-direction-nav">
                    <div class="flex-viewport" style="overflow: hidden; position: relative;">
                        <?php if($have_feature2 || $have_feature3){ ?>
                        <ul class="slides" style="width: 1000%; transition-duration: 0s; transform: translate3d(-1692px, 0px, 0px);">
                    <li class="flex-active-slide" style="width: 564px; float: left; display: block;">
                            <?php the_post_thumbnail(548, 365, true); ?>
                    </li>
                    <?php }else{ ?>
                            <?php the_post_thumbnail(548, 365, true); ?>
                    <?php } ?>
                    <?php if($have_feature2){ ?>
                    <li class="" style="width: 564px; float: left; display: block;">
                           <?php if( class_exists( 'kdMultipleFeaturedImages' ) ) {
                                    kd_mfi_the_featured_image( 'featured-image-2', 'post' );
                                } ?>
                    </li>
                    <?php } ?>
                    <?php if($have_feature3){ ?>
                    <li class="clone" style="width: 564px; float: left; display: block;">
                           <?php if( class_exists( 'kdMultipleFeaturedImages' ) ) {
                                    kd_mfi_the_featured_image( 'featured-image-3', 'post' );
                                } ?>
                    </li>
                    <?php } ?>
                    <?php if($have_feature2 || $have_feature3){ ?> 
                        </ul>
                    <?php } ?>    
                    </div>
            </div>
                </div>
            <div class="span6">
               
		<?php the_content(); ?>
		<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>
                <a class="btn btn-primary" href="<?php echo get_post_meta(get_the_ID(), 'live_preview', true); ?>">Live Preview</a>
                <span class="arrow hlb hidden-phone"></span>
                <h4 class="pull-top">Services</h4>
                <ul class="list icons">
								<li><i class="icon-ok"></i> Design</li>
								<li><i class="icon-ok"></i> HTML/CSS</li>
								<li><i class="icon-ok"></i> Javascript</li>
								<li><i class="icon-ok"></i> Backend</li>
							</ul>
                </div>
	</div><!-- .entry-content -->
        <hr class="tall">
        <div class="row">
            <div class="span12">
                    <h3>Related <strong>Work</strong></h3>
            </div>
            <?php $category = get_the_category();
$catParID = $category[0]->category_parent;
$catParent = get_cat_name ($catParID);
if( $catParent != "Portfolio" )
{
    $catParID = $category[1]->category_parent;    
}
//echo $catParent;
?>
            
            <ul class="portfolio-list">
<?php
$args = array( 'numberposts' => 4, 'orderby' => 'rand','category' => $catParID );
$rand_posts = get_posts( $args );
foreach( $rand_posts as $post ) : ?>
                <li class="span3">
                <div class="portfolio-item thumbnail mobile-max-width">
                   
                    <a class="thumb-info" href="<?php the_permalink(); ?>">
										<?php the_post_thumbnail(); ?>
										<span class="thumb-info-title">
											<span class="thumb-info-inner"> <?php the_title(); ?></span>
											<span class="thumb-info-type"><?php $category = get_the_category();
                        if($category[0]->cat_name == "Portfolio") echo $category[1]->cat_name; else echo $category[0]->cat_name;
                        ?></span>
										</span>
										<span class="thumb-info-action">
											<span class="thumb-info-action-icon" href="#" title="Universal"><i class="icon-link"></i></span>
										</span>
									</a>
        </div>
                    </li>
<?php endforeach; ?>
</ul>
        </div>
	<!--<footer class="entry-meta">
		<?php
			/* translators: used between list items, there is a space after the comma */
			$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );

			/* translators: used between list items, there is a space after the comma */
			$tag_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
			if ( '' != $tag_list ) {
				$utility_text = __( 'This entry was posted in %1$s and tagged %2$s by <a href="%6$s">%5$s</a>. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' );
			} elseif ( '' != $categories_list ) {
				$utility_text = __( 'This entry was posted in %1$s by <a href="%6$s">%5$s</a>. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' );
			} else {
				$utility_text = __( 'This entry was posted by <a href="%6$s">%5$s</a>. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' );
			}

			printf(
				$utility_text,
				$categories_list,
				$tag_list,
				esc_url( get_permalink() ),
				the_title_attribute( 'echo=0' ),
				get_the_author(),
				esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) )
			);
		?>
		<?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>

		<?php if ( get_the_author_meta( 'description' ) && ( ! function_exists( 'is_multi_author' ) || is_multi_author() ) ) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries ?>
		<div id="author-info">
			<div id="author-avatar">
				<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentyeleven_author_bio_avatar_size', 68 ) ); ?>
			</div><!-- #author-avatar -->
			<div id="author-description">
				<h2><?php printf( __( 'About %s', 'twentyeleven' ), get_the_author() ); ?></h2>
				<?php the_author_meta( 'description' ); ?>
				<div id="author-link">
					<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
						<?php printf( __( 'View all posts by %s <span class="meta-nav">&rarr;</span>', 'twentyeleven' ), get_the_author() ); ?>
					</a>
				</div><!-- #author-link	-->
			</div><!-- #author-description -->
		</div><!-- #author-info -->
		<?php endif; ?>
	</footer> .entry-meta -->
</article><!-- #post-<?php the_ID(); ?> -->

		<!-- Libs -->
		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
		<script>window.jQuery || document.write('<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/jquery.js"><\/script>')</script>
		<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/jquery.easing.js"></script>
		<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/jquery.cookie.js"></script>
		<script src="<?php bloginfo('stylesheet_directory'); ?>/master/style-switcher/style.switcher.js"></script> <!-- Style Switcher -->
		<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/bootstrap.js"></script>
		<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/selectnav.js"></script>
		<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/twitterjs/twitter.js"></script>
		<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/flexslider/jquery.flexslider.js"></script>
		<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/jflickrfeed/jflickrfeed.js"></script>
		<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/fancybox/jquery.fancybox.js"></script>
		<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/jquery.validate.js"></script>

		<script src="<?php bloginfo('stylesheet_directory'); ?>/js/plugins.js"></script>

		<!-- Page Scripts -->

		<!-- Theme Initializer -->
		<script src="<?php bloginfo('stylesheet_directory'); ?>/js/theme.js"></script>

		<!-- Custom JS -->
		<script src="<?php bloginfo('stylesheet_directory'); ?>/js/custom.js"></script>